﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using PBMessage;
using UnityEngine.UI;
public class UIBattleView : BaseWidget
{
    GameScene curScene;

    public GameObject[] SkillBtns;
    public override void OnLoad()
    {
        base.OnLoad();
    }

    public void SetUnitAbilityBar()
    {
        curScene = SGLib.Scene.SceneManager.Instance.Cur<GameScene>();
        int i = 0;
        foreach (KeyValuePair<string, Ability> abi in curScene.MainUnit.Abilitys)
        {
            if (abi.Value != curScene.MainUnit.NormalAttack)
            {
                Transform t = SkillBtns[i].transform.GetChild(0);
                t.GetComponent<Text>().text = abi.Value.Name;
                t.parent.name = abi.Value.Name;
                i++;
            }
        }

    }

    public void OnClickNormalAttack()
    {
        CS_RunAbility runAbility = new CS_RunAbility();
        runAbility.AbilityName = curScene.MainUnit.NormalAttack.Name;
        runAbility.UnitId = curScene.MainUnit.GUID;

        Game.Inst.Net.NetClient.Send((int)PBMesasgeID.CS_RunAbility, runAbility);

    }

    public void OnClickAbilityBtn(GameObject go)
    {
        CS_RunAbility runAbility = new CS_RunAbility();
        runAbility.AbilityName = go.name.Trim();
        runAbility.UnitId = curScene.MainUnit.GUID;
        Debug.Log(runAbility.AbilityName.ToString());
        Game.Inst.Net.NetClient.Send((int)PBMesasgeID.CS_RunAbility, runAbility);
    }
}
